﻿using Stee.CAP8.MessageBus.Sagas.Core;
using Stee.CAP8.MessageBus.Sagas.Messages.Events.Payment;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Text;
using System.Threading.Tasks;

namespace Stee.CAP8.MessageBus.Sagas.Payment.Handlers
{
    public class PaymentHandler : 
        IHandleMessages<PayemntEvent>
    {
        IBus _bus;
        public PaymentHandler(IBus bus)
        {
            _bus = bus;
        }


        public Task Handle(PayemntEvent message)
        {
            Console.WriteLine("收到了支付信息" + message.PayMethod + "||" + message.TotalPrice);
            _bus.PublishMessage(new PayemntedEvent
            {
                SagaId= message.SagaId,
                OrderId = message.OrderId,
                PayMethod = "支付已完成",
                requestID = 2,
                TotalPrice = message.TotalPrice

            });
            return Task.CompletedTask;

        }
    }

}
